package cz.muni.fi.pa165.sme.web.common;

import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.form.FormComponent;

/**
 * Appends style of form fields using the css error-style property
 *
 * @author pokornym
 */
public class ErrorBehavior extends Behavior {
	@Override
	public void onComponentTag(final Component component, final ComponentTag tag) {
		if (!((FormComponent) component).isValid()) {
			tag.append("class", "error-style", " ");
		}
	}
}
